const liveModel = require('../model/live')

module.exports = class {
  static async list(ctx) {
    const {cate, title, page, limit} = ctx.request.body
    const data = {
      cate,
      title: new RegExp(title)
    }
    !title && delete data.title
    !cate && delete data.cate

    const list = await liveModel
      .find(data)
      .skip((page-1) * limit)
      .limit(limit)
      .sort({create_time: -1})

    ctx.body = {
      err: 0,
      msg: 'success',
      data: list
    }
    
  }
}